package thread;

public class Demo10 {

    public static void main1(String[] args) throws InterruptedException {
        Thread t = new Thread(()->{
            while(!Thread.currentThread().isInterrupted()){
                System.out.println("thread is running");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    //Thread.currentThread().interrupt();
                    //e.printStackTrace();
                    //break;
                    /*try {
                        Thread.sleep(3000);
                        Thread.currentThread().interrupt();
                    } catch (InterruptedException ex) {
                        ex.printStackTrace();
                    }*/
                }
            }
        });
        t.start();

        Thread.sleep(5000);
        System.out.println(" end the thread");
        t.interrupt();

    }
}
